package org.elfen.common.util;

import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;

public class FileUtil {
	
	public static void inputStream2file(InputStream ins,File file){
		OutputStream os = null;
		try {
			os= new FileOutputStream(file);
			int bytesRead = 0;
			byte[] buffer = new byte[1024];
			while((bytesRead=ins.read(buffer))!=-1){
				os.write(buffer,0,bytesRead);
			}
		} catch (Exception e) {
			e.printStackTrace();
		}finally{
			try {
				if(os!=null) os.close();
				if(ins!=null) ins.close();
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
	}
}
